<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/commond/taglibs.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title>档期网</title>
		<link rel="shortcut icon" href="${ctx }/image/logo_ico.ico" />
		<s:include value="/commond/keydesc.jsp"></s:include>
		<!-- CSS -->
		<link href="${ctx }/css/login_page.css" rel="stylesheet" type="text/css" />
		<link href="${ctx }/css/reg_activate.css" rel="stylesheet" type="text/css" />
		<!-- JavaScript -->
		<script type="text/javascript">
			var activate="<%=(request.getParameter("activate")==null ? "" : request.getParameter("activate")) %>";
			var emailInput="<%=(request.getParameter("emailInput")==null ? "" : request.getParameter("emailInput")) %>";
		</script>
		<script type="text/javascript" src="${ctx }/js/common/jquery.js"></script>
		<script type="text/javascript">var jQ = jQuery.noConflict();</script>
		<script type="text/javascript">
			function isNumber(s){
				return !isNaN(s); 
			}
			jQ(function(){
				if(isNumber(activate)&&activate){
					jQ("#activateresult").css("color","blue");
					jQ("#activateresult2").empty().append("绑定您的手机吧，我们会以短消息形式让您能及时了解您的档期。");
					jQ("#activesuccessmainpart").fadeIn();
				}else{

					jQ.ajax({
						type:"POST",
						url:"userAjax!activite.action",
						data:{
							activate:activate,
							emailInput:emailInput
						},
						success:function(data){
							var dataObj=eval("("+data+")");
							if(dataObj["flag"]){
								jQ("#activateresult").css("color","blue");
								jQ("#activateresult2").empty().append("绑定您的手机吧，我们会以短消息形式让您能及时了解您的档期。");
								jQ("#activesuccessmainpart").fadeIn();
							}else{
								jQ("#activateresult").css("color","red");
								jQ("#activateresult2").empty().append("本页面将在3秒后自动跳转到首页，如果没有跳转，也可以直接进入<a href='./index.html'>首页</a>");
								setTimeout(function(){
								window.location.href=jQ("#ctxVal").val()+"/index.html";
								},3000);
								
							}
							jQ("#activateresult").empty().append(dataObj["result"]);
							/*setTimeout(function(){
								window.location.href=jQ("#ctxVal").val()+"/index.html";
								},3000);*/
						}
					});
				}
				jQ("#verifySendbtn").unbind("click").bind("click",sendVerCode);
				jQ("#mobileipt").val("").attr("disabled","");
				jQ("#veript").val("").attr("disabled","");
				//jQ("#verifyCodebtn").unbind("click").bind("click",verCode);
			});


			var mobilever = new RegExp(/((1(30|31|32|33|34|35|36|37|38|39|45|47|50|51|52|53|54|55|56|57|58|59|80|81|82|83|84|85|86|87|88|89)\d{8,8})|((106|0)\d{10,11}))/img);
			var mobilecode=new RegExp(/(\d{6})/img);

			function resetVerCode(){
				jQ("#sendCodebtn").text("发送验证").unbind("click").bind("click",sendVerCodeConfirm);
				jQ("#mobileipt").attr("disabled","").css({border:"1px solid #7f9db9"});
				jQ("#verifyCodebtn").unbind("click");
			}
			
			function sendVerCode(event){
				var minput=jQ.trim(jQ("#mobileipt").val());
				if(!minput.match(mobilever)){
					showAjaxCallBackMsg(0,"请输入正确的手机号码。");
					return;
				}
				var obj=event.currentTarget;
				jQ.ajax({
					type:"POST",
					url:"userAjax!sendVerCode.action",
					data:{
						mobilenum:minput
					},
					success:function(data){
						var dataObj=eval("("+data+")");
						showAjaxCallBackMsg(eval(dataObj.flag),dataObj.result);
						if(dataObj.flag){
							jQ(obj).text("重新发送").unbind("click").bind("click",resetVerCode);
							jQ("#mobileipt").attr("disabled","disabled").css({border:"0px"});
							jQ("#verifyCodebtn").unbind("click").bind("click",verCode);
						}
					}
				});
			}

			function showAjaxCallBackMsg(flag,msg){
				if(flag){
					jQ("#submitinfo").css({"color":"#583A08"});
					jQ("#submitinfo").empty().append(msg).parent().show();
				}else{
					jQ("#submitinfo").css({"color":"#ff0000"});
					jQ("#submitinfo").empty().append(msg).parent().show();
				}	
			}
			
			function verCode(obj){
				var minput=jQ.trim(jQ("#veript").val());
				if(!minput.match(mobilecode)){
					showAjaxCallBackMsg(0,"验证码只可能是6个数字。");
					return;
				}else{
					jQ.ajax({
						type:"POST",
						url:"userAjax!verifyCode.action",
						data:{
							codenum:minput
						},
						success:function(data){
							var dataObj=eval("("+data+")");
							showAjaxCallBackMsg(eval(dataObj.flag),dataObj.result);
							if(dataObj.flag){
								jQ("#verifyCodebtn").unbind("click");
							}
						}
					});
					
				}
			}
		</script>
	</head>
	<body>
		<div class="login_page">
			<div class="title">
				<div style="background: url('./image/top_fullscreenlight.png') repeat-y; width: 900px; height: 70px; margin: 0px auto;">
			    	<div class="logo" style="margin: 10px 0 0 0;">
			        </div>
		        </div>
		        <input type="hidden" value="${ctx }" id="ctxVal">
		    </div>
		    <div class="activate-part">
			    <div class="head">
			    	<div class="headline1" id="activateresult"></div>
			    	<div class="headline2" id="activateresult2"></div>
			    	
			    </div>
			   <div class="content" id="activesuccessmainpart" style="display: none;">
			    	<div class="contenttitle" >手机绑定</div>
			    	<div style="width: 450px;height: 50px;margin: 0 auto;">
				    	<div class="submitinfo">
				    		<div id="submitinfo" style="padding:10px 10px 0px 15px;">
				    		</div>
				    	</div>
			    	</div>
			    	<div class="main" style="width: 500px;font-size: 12px;margin:0 auto;">
			    		<ul style="list-style: none outside none;">
			    			<li style="padding:2px 0; margin-left: 0px;height: 36px;" >
					    		<span style="float: left;line-height: 26px;">手机号:</span>
					    		<span style="float: left;margin-left: 6px;"><input type="text" id="mobileipt" style="width: 100px;height: 16px;" onfocus="jQ('#submitinfo').empty().parent().hide();"/></span>
					    		<span style="float: left;"><button id="verifySendbtn" class="verifybtn" style="margin-left: 30px;width: 90px;">发送验证</span>
			    			</li>
			    			<li style="padding:20px 0; margin-left: 0px;" >
			    				<span style="float: left;line-height: 26px;">验证码: </span>
			    				<span style="float: left;margin-left: 6px;"><input type="text" id="veript" style="width: 50px; float: left; margin-top: 2px;height: 16px;" maxlength="6" onfocus="jQ('#submitinfo').empty().parent().hide();"/></span>
			    				<button class="verifybtn" id="verifyCodebtn" style="float: left; margin-left:80px;width: 90px;">验证</button>
			    			</li>
			    		</ul>
			    		<br/>
			    		<br/>
			    		<div style="color: #2979b5; width: 418px; padding: 20px;font-size: 13px;font-weight: bold;margin: 0 auto;">
			    			<p style="margin-top: 0px;">
				    			<span style="color: #ff0000;">P.S. </span>您仍可以在控制面板中的个人信息中，
			    			</p>
			    			<p style="text-indent: 40px;margin-top: 0px;">
				    			修改或绑定您的手机号。
			    			</p>
			    		</div>
			    		<div style="width: auto;float:right;color:#ff0000;font-size: 14px;"><span onclick="window.location.href='./index.html'" style="cursor: pointer;text-decoration: underline;">跳过本步骤直接进入首页</span></div>
			    	</div>
			    </div>
		    </div>
		    <div class="copyright" style="margin-top: 50px;padding: 20px 0;">
		    	<span>Copyright &copy; 2011 档期</span>
		    </div>
		</div>
	</body>
</html>